<template>
    <div>
       <input type="text" placeholder="请输入你的任务名称，按回车键确认" @keyup.enter="add"> 
    </div>
</template>

<script>
import {nanoid} from 'nanoid'
export default {
    name: 'MyHeader',
    data() {
        return {
            
        };
    },
    props:['addTodo'],
    mounted() {
        
    },

    methods: {
        add(e){
            //console.log(e.target.value)
            const todoObj = {id:nanoid(),title:e.target.value,done:false}
            //console.log(todoObj)
            if(e.target.value === ''){return}
            this.addTodo(todoObj)
            e.target.value=''
        }
    },
};
</script>

<style lang="scss" scoped>

</style>